package com.leyou.search.feignclient;

import com.leyou.common.domain.PageResult;
import com.leyou.dto.*;
import com.leyou.search.feignclient.impl.DemoFallBackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @version V1.0
 * @author: Ljxpa
 * @date: 2020/03/11 17:04
 * @description:
 */
@FeignClient(value = "item-service",fallbackFactory = DemoFallBackFactory.class)//value值为eureka中服务提供者的name，这里会自动拼接出http://127.0.0.1:8001,如果服务提供者是集群，会调用ribbon中的负载均衡

public interface ItemClient {

	@GetMapping("/spu/page")
	PageResult<SpuDto> pageQuerySpu(
			@RequestParam(value = "key", required = false) String key,
			@RequestParam(value = "saleable", required = false) Boolean saleable,
			@RequestParam(value = "page", defaultValue = "1") Integer page,
			@RequestParam(value = "rows", defaultValue = "5") Integer rows
	);

	@GetMapping("/sku")
	List<SkuDTO> querySkuBySpuId(@RequestParam("spuId") Long spuId);

	@GetMapping("/category/list")
	List<CategoryDto> queryCategoriesByCids(@RequestParam("cids") List<Long> cids);

	@GetMapping("/of/{id}")
	BrandDto queryBrandByBranId(@PathVariable("id") Long brandId);

	@GetMapping("/spec/params/searching")
	List<SpecParamDTO> querySearchingParamsCategoryId(@RequestParam(required = false) Long cid, @RequestParam(required = false) Boolean searching);

	@GetMapping("/spudetail/{id}")
	SpuDetailDTO querySpuDetailBySpuId(@PathVariable("id") Long id);

	@GetMapping("/brand/list")
	List<BrandDto> queryBrandsByBrandIds(@RequestParam("bids")List<Long> bids);

	@GetMapping("/spec/params/searching")
	List<SpecParamDTO> queryParamsByGroupIdOrCategoryId(
			@RequestParam(required = false) Long cid,
			@RequestParam(required = false) Boolean searching);

	@GetMapping("/category/list/cid3")
	List<CategoryDto> queryCategoriesByCid3(@RequestParam("cid3") Long cid3);
}
